// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod cloud_quotas {
    use crate::Result;

    /// A builder for [CloudQuotas][crate::client::CloudQuotas].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_api_cloudquotas_v1::*;
    /// # use builder::cloud_quotas::ClientBuilder;
    /// # use client::CloudQuotas;
    /// let builder : ClientBuilder = CloudQuotas::builder();
    /// let client = builder
    ///     .with_endpoint("https://cloudquotas.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::CloudQuotas;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = CloudQuotas;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::CloudQuotas] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [CloudQuotas::list_quota_infos][crate::client::CloudQuotas::list_quota_infos] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::ListQuotaInfos;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListQuotaInfos {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListQuotaInfos(RequestBuilder<crate::model::ListQuotaInfosRequest>);

    impl ListQuotaInfos {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListQuotaInfosRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListQuotaInfosResponse> {
            (*self.0.stub)
                .list_quota_infos(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListQuotaInfosResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListQuotaInfosResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListQuotaInfosRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListQuotaInfosRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListQuotaInfosRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListQuotaInfos {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CloudQuotas::get_quota_info][crate::client::CloudQuotas::get_quota_info] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::GetQuotaInfo;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetQuotaInfo {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetQuotaInfo(RequestBuilder<crate::model::GetQuotaInfoRequest>);

    impl GetQuotaInfo {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetQuotaInfoRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QuotaInfo> {
            (*self.0.stub)
                .get_quota_info(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetQuotaInfoRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetQuotaInfo {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CloudQuotas::list_quota_preferences][crate::client::CloudQuotas::list_quota_preferences] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::ListQuotaPreferences;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListQuotaPreferences {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListQuotaPreferences(RequestBuilder<crate::model::ListQuotaPreferencesRequest>);

    impl ListQuotaPreferences {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListQuotaPreferencesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListQuotaPreferencesResponse> {
            (*self.0.stub)
                .list_quota_preferences(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListQuotaPreferencesResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListQuotaPreferencesResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListQuotaPreferencesRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListQuotaPreferencesRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListQuotaPreferencesRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListQuotaPreferencesRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::ListQuotaPreferencesRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListQuotaPreferences {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CloudQuotas::get_quota_preference][crate::client::CloudQuotas::get_quota_preference] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::GetQuotaPreference;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetQuotaPreference {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetQuotaPreference(RequestBuilder<crate::model::GetQuotaPreferenceRequest>);

    impl GetQuotaPreference {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetQuotaPreferenceRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
            (*self.0.stub)
                .get_quota_preference(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetQuotaPreferenceRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetQuotaPreference {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CloudQuotas::create_quota_preference][crate::client::CloudQuotas::create_quota_preference] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::CreateQuotaPreference;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateQuotaPreference {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateQuotaPreference(RequestBuilder<crate::model::CreateQuotaPreferenceRequest>);

    impl CreateQuotaPreference {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateQuotaPreferenceRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
            (*self.0.stub)
                .create_quota_preference(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateQuotaPreferenceRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [quota_preference_id][crate::model::CreateQuotaPreferenceRequest::quota_preference_id].
        pub fn set_quota_preference_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.quota_preference_id = v.into();
            self
        }

        /// Sets the value of [quota_preference][crate::model::CreateQuotaPreferenceRequest::quota_preference].
        ///
        /// This is a **required** field for requests.
        pub fn set_quota_preference<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::QuotaPreference>,
        {
            self.0.request.quota_preference = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [quota_preference][crate::model::CreateQuotaPreferenceRequest::quota_preference].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_quota_preference<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::QuotaPreference>,
        {
            self.0.request.quota_preference = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ignore_safety_checks][crate::model::CreateQuotaPreferenceRequest::ignore_safety_checks].
        pub fn set_ignore_safety_checks<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::QuotaSafetyCheck>,
        {
            use std::iter::Iterator;
            self.0.request.ignore_safety_checks = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateQuotaPreference {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CloudQuotas::update_quota_preference][crate::client::CloudQuotas::update_quota_preference] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_api_cloudquotas_v1::builder;
    /// use builder::cloud_quotas::UpdateQuotaPreference;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateQuotaPreference {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateQuotaPreference(RequestBuilder<crate::model::UpdateQuotaPreferenceRequest>);

    impl UpdateQuotaPreference {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudQuotas>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateQuotaPreferenceRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::QuotaPreference> {
            (*self.0.stub)
                .update_quota_preference(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [update_mask][crate::model::UpdateQuotaPreferenceRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateQuotaPreferenceRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [quota_preference][crate::model::UpdateQuotaPreferenceRequest::quota_preference].
        ///
        /// This is a **required** field for requests.
        pub fn set_quota_preference<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::QuotaPreference>,
        {
            self.0.request.quota_preference = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [quota_preference][crate::model::UpdateQuotaPreferenceRequest::quota_preference].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_quota_preference<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::QuotaPreference>,
        {
            self.0.request.quota_preference = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::UpdateQuotaPreferenceRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }

        /// Sets the value of [validate_only][crate::model::UpdateQuotaPreferenceRequest::validate_only].
        pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.validate_only = v.into();
            self
        }

        /// Sets the value of [ignore_safety_checks][crate::model::UpdateQuotaPreferenceRequest::ignore_safety_checks].
        pub fn set_ignore_safety_checks<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::QuotaSafetyCheck>,
        {
            use std::iter::Iterator;
            self.0.request.ignore_safety_checks = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateQuotaPreference {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
